//
//  GAKKIBaseTextField.m
//  GANGAIKit
//
//  Created by fh on 2019/11/6.
//  Copyright © 2019 cashchina. All rights reserved.
//

#import "GAKKIBaseTextField.h"

@implementation GAKKIBaseTextField
- (void)dealloc {
    if (kDebugViewRelease) {
#ifdef DEBUG
        DBLog(@"\n ----------- TextField %@ 销毁了 ----------- \n",[self class]);
#endif
    }
}

+ (instancetype)initGAKKIBaseTextField {
    GAKKIBaseTextField *textField = [GAKKIBaseTextField new];
    textField.font = [UIFont systemFontOfSize:16];
    textField.textAlignment = NSTextAlignmentLeft;
    textField.textColor = [UIColor blackColor];
    return textField;
}

+ (GAKKIBaseTextField *)gakki_makeTextField:(void (^)(GAKKIBaseTextField * _Nonnull))block {
    GAKKIBaseTextField *textField = [GAKKIBaseTextField initGAKKIBaseTextField];
    if (block) {
        block(textField);
    }
    return textField;
}

- (GAKKITextFieldFrame)gakki_frame {
    return ^(CGRect frame) {
        self.frame = frame;
        return self;
    };
}
- (GAKKITextFieldBackgroundColor)gakki_backgroundColor {
    return ^(UIColor * __nullable backgroundColor) {
        self.backgroundColor = backgroundColor;
        return self;
    };
}
- (GAKKITextFieldText)gakki_text {
    return ^(NSString * __nullable text) {
        self.text = text;
        return self;
    };
}
- (GAKKITextFieldFont)gakki_font {
    return ^(UIFont * __nullable font) {
        self.font = font;
        return self;
    };
}
- (GAKKITextFieldTextColor)gakki_textColor {
    return ^(UIColor * __nullable textColor) {
        self.textColor = textColor;
        return self;
    };
}
- (GAKKITextFieldTextAlignment)gakki_textAlignment {
    return ^(NSTextAlignment textAlignment) {
        self.textAlignment = textAlignment;
        return self;
    };
}
- (GAKKITextFieldAttributedString)gakki_attributedText {
    return ^(NSAttributedString * __nullable attributedText) {
        self.attributedText = attributedText;
        return self;
    };
}

- (GAKKITextFieldBorderStyle)gakki_borderStyle {
    return ^(UITextBorderStyle borderStyle) {
        self.borderStyle = borderStyle;
        return self;
    };
}
- (GAKKITextFieldPlaceholder)gakki_placeholder {
    return ^(NSString * __nullable placeholder) {
        self.placeholder = placeholder;
        return self;
    };
}
- (GAKKITextFieldAttributedPlaceholder)gakki_attributedPlaceholder {
    return ^(NSAttributedString * __nullable attributedPlaceholder) {
        self.attributedPlaceholder = attributedPlaceholder;
        return self;
    };
}
- (GAKKITextFieldClearsOnBeginEditing)gakki_clearsOnBeginEditing {
    return ^(BOOL clearsOnBeginEditing) {
        self.clearsOnBeginEditing = clearsOnBeginEditing;
        return self;
    };
}
- (GAKKITextFieldAdjustsFontSizeToFitWidth)gakki_adjustsFontSizeToFitWidth {
    return ^(BOOL adjustsFontSizeToFitWidth) {
        self.adjustsFontSizeToFitWidth = adjustsFontSizeToFitWidth;
        return self;
    };
}
- (GAKKITextFieldMinimumFontSize)gakki_minimumFontSize {
    return ^(CGFloat minimumFontSize) {
        self.minimumFontSize = minimumFontSize;
        return self;
    };
}
- (GAKKITextFieldDelegate)gakki_delegate {
    return ^(id<UITextFieldDelegate> __nullable delegate) {
        self.delegate = delegate;
        return self;
    };
}
- (GAKKITextFieldClearButtonMode)gakki_clearButtonMode {
    return ^(UITextFieldViewMode clearButtonMode) {
        self.clearButtonMode = clearButtonMode;
        return self;
    };
}
- (GAKKITextFieldEnabled)gakki_enabled {
    return ^(BOOL enabled) {
        self.enabled = enabled;
        return self;
    };
}

@end
